library(psych)

pca <- function(data, size) {
    cor.matrix <- cor(data)
    data$pca <- principial(r = cor.matrix, nfactors = size, residuals = FALSE, rotate = "varimax")
}
